<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

use app\common\model\ForumBbsCategory;
use app\common\model\ForumBbsLevel;
use app\common\model\activeCategory;
use app\common\model\GamblerKing;

/**
 * 活动控制器
 */
class Active extends AdminBase
{

    /**
     * 活动列表
     */
    public function activeList()
    {

        // $where = $this->logicactive->getWhere($this->param);

        $this->assign('list', $this->logicactive->getactiveList($this->param, 'a.*', 'a.create_time desc'));
        $this->assign('tags', GamblerKing::all(['status'=>1]));
        $this->assign('param', $this->param);
        return $this->fetch('active_list');
    }


    /**
     * 活动门票列表
     */
    public function ticketList()
    {

        // $where = $this->logicactive->getWhere($this->param);

        $this->assign('list', $this->logicactive->getticketList($this->param, 'a.*', 'a.create_time desc'));
        $this->assign('active_id', $this->param['active_id']);
        return $this->fetch('ticket_list');
    }

    /**
     * 活动门票添加
     */
    public function ticketAdd()
    {

        $this->activeTicketCommon();

        $this->assign('active_id', $this->param['active_id']);
        return $this->fetch('ticket_edit');
    }

    /**
     * 活动编辑
     */
    public function ticketEdit()
    {

        $this->activeTicketCommon();

        $info = $this->logicactive->getticketInfo(['a.id' => $this->param['id']], 'a.*');


        $this->assign('info', $info);
        //dd( $info['active_id']);
        $this->assign('active_id', $info['active_id']);
        return $this->fetch('ticket_edit');
    }

    /**
     * 活动添加
     */
    public function activeAdd()
    {

        $this->activeCommon();

        return $this->fetch('active_edit');
    }

    /**
     * 活动编辑
     */
    public function activeEdit()
    {

        $this->activeCommon();

        $info = $this->logicactive->getactiveInfo(['a.id' => $this->param['id']], 'a.*');


        $this->assign('info', $info);
      //  $this->assign('tags', GamblerKing::all(['status'=>1]));
        return $this->fetch('active_edit');
    }

    /**
     * 活动添加与编辑通用方法
     */
    public function activeCommon()
    {

//      IS_POST && $this->jump($this->logicactive->activeEdit($this->param));
        IS_POST && $this->jump($this->logicactive->activeEdit($_POST));
        $this->assign('tags', GamblerKing::all(['status'=>1]));


    }


    /**
     * 活动门票添加与编辑通用方法
     */
    public function activeTicketCommon()
    {

//      IS_POST && $this->jump($this->logicactive->activeEdit($this->param));
        IS_POST && $this->jump($this->logicactive->ticketEdit($_POST));

        $this->assign('tags', GamblerKing::all(['status'=>1]));

    }


    /**
     * 数据状态设置
     */
    public function setStatus()
    {

        $this->jump($this->logicAdminBase->setStatus('Active', $this->param));
    }


    /**
     * 数据状态设置
     */
    public function delTicket()
    {

        $this->jump($this->logicAdminBase->setStatus('ActiveTicket', $this->param));
    }


    /**
     * 数据状态设置
     */
    public function update_info()
    {

        $this->jump($this->logicactive->update_info( $this->param));
    }







}
